package com.example.myProxy;

import org.springframework.beans.factory.config.AbstractFactoryBean;

import java.lang.reflect.Proxy;

public class MyFactory extends AbstractFactoryBean {

//    @Override
//    public Object getObject() throws Exception {
//        return (MyInterface)Proxy.newProxyInstance(MyInterface.class.getClassLoader(), new Class[] { MyInterface.class }, new MyProxy());
//    }

    @Override
    public Class<?> getObjectType() {
        return MyInterface.class;
    }

    @Override
    protected Object createInstance() throws Exception {
        return (MyInterface)Proxy.newProxyInstance(MyInterface.class.getClassLoader(), new Class[] { MyInterface.class }, new MyProxy());
    }

}
